public class Massage{
    private String bookName;
    private String authorName;
    private int price;
    private int id;
    private boolean lendStatu = false;

    Massage(String bookName, String authorName, int price, int id,boolean LendStatus){
            this.bookName = bookName;
            this.authorName = authorName;
            this.price = price;
            this.id = id;
            this.lendStatu = LendStatus;
    }

    public String getMassage(){
        StringBuffer tmpBookName = new StringBuffer(bookName);
        while(getStringLength(tmpBookName)>40){
            tmpBookName.deleteCharAt(tmpBookName.length()-1);
        }
        while(getStringLength(tmpBookName)<40){
            tmpBookName.append(" ");
        }
        StringBuffer tmpauthorName = new StringBuffer(authorName);
        while(getStringLength(tmpauthorName)>40){
            tmpauthorName.deleteCharAt(tmpauthorName.length()-1);
        }
        while(getStringLength(tmpauthorName)<40){
            tmpauthorName.append(" ");
        }
        String ret = " " + bookName + "    " + authorName + "      " + price + "元          " + id;
        if(lendStatu == true){
            ret += "        Lend Status";
        }else if(lendStatu == false){
            ret += "        In Lib";
        }
        return ret;
    }

    public String getBookName(){
        return bookName;
    }

    public String getAuthorName(){
        return authorName;
    }

    public int getPrice(){
        return price;
    }

    public int getId(){
        return id;
    }

    public void changId(int n){
        id = n;
    }

    public boolean getLendStatu(){
        return lendStatu;
    }

    public void setLendStatu(boolean lendStatu){
        this.lendStatu = lendStatu;
    }

    public static int getStringLength(StringBuffer str){
        int ret = 0;
        for(int i=0; i<str.length(); i++){
            if(str.charAt(i) > 255){
                ret++;
            }
            ret++;
        }
        return ret;
    }
    @Override
    public String toString(){
        return getMassage();
    }
}
